
import { userInfoAPI } from '@/request/api'
export default {
    namespaced: true,
    state: {
        cartTotal: 0,
        userInfo: {
            nickName: '游客',
            coin: '--',
            headImg: require('@/assets/img/userImg.f8bbec5e.png')
        }
    },
    mutations: {
        changeUserInfo(state, payload) {
            state.cartTotal = payload.cartTotal;
            state.userInfo = payload.userInfo;
        },
        initUserInfo(state) {
            state.cartTotal = 0;
            state.userInfo = {
                nickName: '游客',
                coin: '--',
                headImg: require('@/assets/img/userImg.f8bbec5e.png')
            }
        }
    },
    actions: {
        async asyncChangeUserInfo({ commit }, payload) {
            let res = await userInfoAPI();
            commit('changeUserInfo', res.data)
        }
    }
}